package com.ks.pc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ks.dto.OtherDto;
import com.ks.pc.service.SysOtherService;

@Controller
@RequestMapping("/pc")
public class PcController {

	@Autowired
	private SysOtherService sysOtherService;

	/**
	 * PC端首页
	 * 
	 * @param brandId
	 * @param iemtSearchTxt
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/pcHome", method = RequestMethod.GET)
	public String pcHomeView(String brandId, String iemtSearchTxt, Model model) {
		model.addAttribute("brandId", brandId); // 左则导航菜单栏条件点入
		model.addAttribute("iemtSearchTxt", iemtSearchTxt); // 在item界面，头部点入
		return "biz/pcHome";
	}

	/**
	 * 在线办理
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/pcOnlineOpt", method = RequestMethod.GET)
	public String pcOnlineOptView(Model model) {
		return "biz/pcOnlineOpt";
	}

	/**
	 * 办理条件
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/pcContact", method = RequestMethod.GET)
	public String pcContactView(Model model) {
		OtherDto otherDto = sysOtherService.findOtherById(2);
		if (null != otherDto) {
			model.addAttribute(otherDto);
		}
		return "biz/pcContact";
	}

	/**
	 * 关于我们
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/pcAbout", method = RequestMethod.GET)
	public String pcAboutView(Model model) {
		OtherDto otherDto = sysOtherService.findOtherById(1);
		if (null != otherDto) {
			model.addAttribute(otherDto);
		}
		return "biz/pcAbout";
	}

	/**
	 * 所有产品
	 * @param classifyId
	 * @param brandId
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/pcProductList", method = RequestMethod.GET)
	public String pcProductListView(Integer classifyId, Integer brandId, Model model) {
		if (null != classifyId && 9999 != classifyId) {
			model.addAttribute("classifyId", classifyId);
		}
		if (null != brandId && 9999 != brandId) {
			model.addAttribute("classifyId", classifyId);
			model.addAttribute("brandId", brandId);
		}
		return "biz/pcProductList";
	}

	/**
	 * 产品明细
	 * @param productId
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/pcIemt", method = RequestMethod.GET)
	public String pcIemtView(Integer productId, Model model) {
		model.addAttribute("productId", productId);
		return "biz/pcIemt";
	}

}
